#define MYNAME "GPX"
#define MY_CBUF_SZ 4096
#define DEFAULT_XSI_SCHEMA_LOC "http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"
+#define DEFAULT_XSI_SCHEMA_LOC_11 "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
#define DEFAULT_XSI_SCHEMA_LOC_FMT "\"http://www.topografix.com/GPX/%c/%c http://www.topografix.com/GPX/%c/%c/gpx.xsd\""
#ifndef CREATOR_NAME_URL
# define CREATOR_NAME_URL "GPSBabel - http://www.gpsbabel.org"
static void
tag_gpx(const char **attrv)
{
- const char **avp = &attrv[0];
- while (*avp) {
+ const char **avp;
+ for (avp = &attrv[0]; *avp; avp += 2) {
if (strcmp(avp[0], "version") == 0) {
gpx_version = avp[1];
}
else if (strcmp(avp[0], "src") == 0) {
gpx_creator = avp[1];
}
+ /*
+ * Our handling of schemaLocation really is weird.
+ * If we see we have a "normal" GPX 1.1 header, on read,
+ * flip our default on write to use that and don't append
+ * it to the rest...
+ */
else if (strcmp(avp[0], "xsi:schemaLocation") == 0) {
+ if (0 == strcmp(avp[1], DEFAULT_XSI_SCHEMA_LOC_11)) {
+ if (0 == strcmp(xsi_schema_loc, DEFAULT_XSI_SCHEMA_LOC))
+ xfree(xsi_schema_loc);
+ xsi_schema_loc = xstrdup(DEFAULT_XSI_SCHEMA_LOC_11);
+ continue;
+ }
if (0 == strstr(xsi_schema_loc, avp[1])) {
xsi_schema_loc = xstrappend(xsi_schema_loc, " ");
xsi_schema_loc = xstrappend(xsi_schema_loc, avp[1]);
}
}
- avp+=2;
}
}
lt = xstrdup(lrtrim(link_text));
}
- fprintf(stderr, "Here %s/%s\n", link_url, lt);
add_url(wpt_tmp, xstrdup(link_url), lt);
link_text = NULL;
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<gpx
+ version="1.1"
+creator="GPSBabel - http://www.gpsbabel.org"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xmlns="http://www.topografix.com/GPX/1/1"
+xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
+<metadata>
+<time>1970-01-01T00:00:00Z</time>
+<bounds minlat="21.278604576" minlon="-157.810719665" maxlat="21.278604576" maxlon="-157.810719665"/>
+</metadata>
+<wpt lat="21.278604576" lon="-157.810719665">
+<time>2007-03-10T22:41:34Z</time>
+ <name>001</name>
+ <cmt>3348 Martha St</cmt>
+ <desc>3348 Martha St</desc>
+ <link href="www.one.com">
+ <text>one</text>
+ </link>
+ <link href="www.two.com">
+ <text>two dots</text>
+ </link>
+ <link href="www.twoandahalf.com">
+ </link>
+ <link href="www.three.com">
+ <text>three dots</text>
+ </link>
+ <sym>Waypoint</sym>
+ <extensions>
+ <gpxx:WaypointExtension xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.garmin.com/xmlschemas/GpxExtensions/v2 http://www.garmin.com/xmlschemas/GpxExtensions/v2/GpxExtensionsv2.xsd">
+ <gpxx:DisplayMode>SymbolAndDescription</gpxx:DisplayMode>
+ </gpxx:WaypointExtension>
+ </extensions>
+</wpt>
+</gpx>
<?xml version="1.0" encoding="UTF-8"?>
<gpx
- version="1.0"
+ version="1.1"
creator="GPSBabel - http://www.gpsbabel.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-xmlns="http://www.topografix.com/GPX/1/0"
-xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
+xmlns="http://www.topografix.com/GPX/1/1"
+xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
+<metadata>
<time>1970-01-01T00:00:00Z</time>
<bounds minlat="42.401051000" minlon="-71.126602000" maxlat="42.468655000" maxlon="-71.102973000"/>
+</metadata>
<rte>
<rtept lat="42.438878000" lon="-71.119277000">
<ele>44.586548</ele>
<?xml version="1.0" encoding="UTF-8"?>
<gpx
- version="1.0"
+ version="1.1"
creator="GPSBabel - http://www.gpsbabel.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-xmlns="http://www.topografix.com/GPX/1/0"
-xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
+xmlns="http://www.topografix.com/GPX/1/1"
+xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
+<metadata>
<time>1970-01-01T00:00:00Z</time>
<bounds minlat="42.430950000" minlon="-71.122845000" maxlat="42.467110000" maxlon="-71.105116000"/>
+</metadata>
<wpt lat="42.430950000" lon="-71.107628000">
<ele>23.469600</ele>
<time>2001-06-02T00:18:15Z</time>
# Transformation filter (transform) tests
#
rm -f ${TMPDIR}/transform*
-${PNAME} -i gpx -f ${REFERENCE}/expertgps.gpx -x nuketypes,routes,tracks -x transform,rte=wpt,del=y -o gpx -F ${TMPDIR}/transform-rte.gpx
+${PNAME} -i gpx -f ${REFERENCE}/expertgps.gpx -x nuketypes,routes,tracks -x transform,rte=wpt,del=y -o gpx,gpxver=1.1 -F ${TMPDIR}/transform-rte.gpx
compare ${TMPDIR}/transform-rte.gpx ${REFERENCE}/transform-rte.gpx
-${PNAME} -i gpx -f ${REFERENCE}/expertgps.gpx -x nuketypes,waypoints,tracks -x transform,wpt=rte,del=y -o gpx -F ${TMPDIR}/transform-wpt.gpx
+${PNAME} -i gpx -f ${REFERENCE}/expertgps.gpx -x nuketypes,waypoints,tracks -x transform,wpt=rte,del=y -o gpx,gpxver=1.1 -F ${TMPDIR}/transform-wpt.gpx
compare ${TMPDIR}/transform-wpt.gpx ${REFERENCE}/transform-wpt.gpx
#
${PNAME} -i alantrl -f ${TMPDIR}/alantrl-new.trl -o gpx -F ${TMPDIR}/alantrl-new.gpx
compare ${TMPDIR}/alantrl-new.gpx ${REFERENCE}/alantrl.gpx
+#
+# Test > 1 URL in selected files.
+#
+rm -f ${TMPDIR}/mlink*
+${PNAME} -i gpx -f reference/multiple-links.gpx -o gpx,gpxver=1.1 -F ${TMPDIR}/mlink-1.gpx
+compare ${TMPDIR}/mlink-1.gpx reference/multiple-links.gpx
+
exit 0